package src;

import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class InputHandler implements KeyListener, MouseListener{
	
	boolean[] keyArray = new boolean[256];
	boolean leftClick = false, rightClick = false; 
	
	public InputHandler(Component c){
		c.addKeyListener(this);
		c.addMouseListener(this);
	}
	
	public boolean isKeyDown(int KeyCode){
		return keyArray[KeyCode];
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
		if(e.getButton() == MouseEvent.BUTTON1){
			leftClick = true;
		}else if(e.getButton() == MouseEvent.BUTTON3){
			rightClick = true;
		}
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		if(e.getButton() == MouseEvent.BUTTON1){
			leftClick = false;
		}else if(e.getButton() == MouseEvent.BUTTON3){
			rightClick = false;
		}
	}

	@Override
	public void keyPressed(KeyEvent e) {
		keyArray[e.getKeyCode()] = true;
	}

	@Override
	public void keyReleased(KeyEvent e) {
		keyArray[e.getKeyCode()] = false;
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}

}
